<?php

class Location extends Eloquent
{
    protected $guarded = array();
    public static $rules = array();

    public function branch()
    {
        return $this->belongsTo('ProvincePlaces', 'branch_id');
    }
    /**
     * Get the date the post was created.
     *
     * @param  \Carbon|null $date
     * @return string
     */
    public function date($date=null)
    {
        if (is_null($date)) {
            $date = $this->created_at;
        }

        return String::date($date);
    }

    /**
     * Returns the date of the blog post creation,
     * on a good and more readable format :)
     *
     * @return string
     */
    public function created_at()
    {
        return $this->date($this->created_at);
    }

    /**
     * Returns the date of the blog post last update,
     * on a good and more readable format :)
     *
     * @return string
     */
    public function updated_at()
    {
        return $this->date($this->updated_at);
    }

    public function getPresenter()
    {
        return new PostPresenter($this);
    }

    public function getAtmByProvince($provinceId)
    {
        return self::where('province_id', $province_id)->first();
    }
    public function getAtmByProvinceAndBank($province_id, $bank_id)
    {
        return self::where('province_id', $province_id)
                    ->where('place_id', $bank_id)
                    ->get();
    }

}
